#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int majorityElement(int* nums, int numsSize)
{
    int i = 0;
    int j = 0;
    int count = 0;
    for (i = 0; i < numsSize; i++)
    {
        for (j = 0; j < numsSize; j++)
        {
            if (nums[i] == nums[j])
            {
                count++;
            }
        }
        if (count > numsSize / 2)
        {
            break;
        }
        else
        {
            count = 0;
        }
    }
    return nums[i];
}
int cmp(const void* e1, const void* e2)
{
    return *(int*)e1 - *(int*)e2;
}
int majorityElement2(int* nums, int numsSize)
{
    qsort(nums, numsSize, sizeof(int), cmp);
    return nums[numsSize / 2];
}
int main()
{
    int arr[3] = { 3,3,4 };
    int i = majorityElement(arr, 3);
    printf("%d\n", i);
    return 0;
}
